package com.cq.hd.order.factory;

import java.util.HashMap;
import java.util.Map;

public class OrderFactory {

    private static final Map<Integer, AbstractOrderHandler> STRATEGY_MAP = new HashMap<>();

    public static void register(Integer markType, AbstractOrderHandler strategy) {
        STRATEGY_MAP.put(markType, strategy);
    }

    public static AbstractOrderHandler getOrderHandler(Integer type) {
        AbstractOrderHandler abstractOrderHandler = STRATEGY_MAP.get(type);
        if (abstractOrderHandler == null) {
            throw new RuntimeException("处理类为空");
        }
        return abstractOrderHandler;
    }

}
